function [ y ] = LL(theta)
load('mainfile1.mat');
alpha=theta(1);
beta=theta(2:6); % <1x5 double>
mu=theta(7:31);  % <1x25 double>
lambda=theta(32);
gamma=theta(33);
chi=theta(34:58);% <1x25 double>
rho=theta(59:63);
c=theta(64);

sum=0;
for id=2:1:2
    mihat=mi(theta, id)
    mishat=exp(mis(theta,id))
    Pis=mishat/exp(mihat)

    n=find(consumer_id==id);
    z=find((jean==1)&(consumer_id==id)); % selected product for consumer i==id
    j=brandid(z); %%%%%%%%%%%%%%%%%%

    k=dimension(n(1)); % dimension of subset of stores S_{i}  
    p=x(n(1),:)*beta';
    m1=n(1);
    m2=n(1)+k-1;
    s= brandid(m1:m2)'; % subset of stores S_{i}=[2 4 8 17]
    temp1=alpha*store_totprice(j)+mu(j)+p+gamma*duration(j);%+lambda*pages_viewed(j)
    top=exp(temp1);
    
    bottom=0;
    for l=1:1:k
        r=s(l); % brand r \in [2 4 8 17]
        temp2=alpha*store_totprice(r)+mu(r)+p+gamma*duration(r);
        bottom=bottom+exp(temp2);
    end 
    pijs=top/(1+bottom)
    loglikelihood=log(Pis*pijs);
    sum=sum+loglikelihood;
end 
y=-sum;
end

